package com.liuyk.commonlib.network;

import android.text.TextUtils;

/**
 * 网络初始化
 * <p>
 * Created by liuyakui on 2020/6/24
 */
public class ApiInit {
    private ApiInterface apiInterface;
    private NetBuilder.Builder builder;

    private ApiInit() {

    }

    public static ApiInit getInstance() {
        return Inner.INSTANCE;
    }

    public NetBuilder.Builder builder(String host) {
        builder = new NetBuilder.Builder(TextUtils.isEmpty(host) ? "http://def" : host);
        return builder;
    }

    public void init() {
        apiInterface = builder.build(ApiInterface.class, 10);
    }

    public NetBuilder.Builder getBuilder() {
        return builder;
    }

    public ApiInterface getApiInterface() {
        return apiInterface;
    }

    private static class Inner {
        public static final ApiInit INSTANCE = new ApiInit();
    }
}
